package cn.onecloud.examples;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.onecloud.examples.database.CommonHqlDao;

/**
 * This Service use common dao
 * 
 * @author Keijack
 */
@Service
public class StudentService {

    @Autowired
    private CommonHqlDao dao;

    public List<Student> list(QueryStudentParam params) {
	return dao.query(Student.class, params);
    }

    public void add(String name) {
	Student student = new Student();
	student.setName(name);
	student.setCreateTime(new Date());
	dao.save(student);
    }

    public void update(Integer id, String name) {
	Student student = dao.get(Student.class, id);
	student.setName(name);
	dao.update(student);
    }
}
